<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%--
  Created by IntelliJ IDEA.
  User: 肖林
  Date: 2018/4/3
  Time: 17:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改</title>
</head>
<body>
<%
    String id=request.getParameter("id");
    String username=request.getParameter("usm");
    String password=request.getParameter("psd");
%>
    <form method="post">
        username:<input type="text" name="username" value="<%=username%>">
        </br>
        password:<input type="password" name="password" value="<%=password%>">
         </br>
        <input type="submit" value="修改">
       <a href="lab01.jsp"><input type="button" value="返回" ></a>

    </form>
<%

     String id1 = request.getParameter("id");
    String name = request.getParameter("username");
    String psd=request.getParameter("password");

    Connection connection=null;
    Statement statement=null;
   // ResultSet resultSet=null;

    String sql="UPDATE t_user set username='"+name+"',password='"+psd+"' where id='"+id1+"'";

    Class.forName("com.mysql.jdbc.Driver");
    connection=DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/javaweb_2018?serverTimezone = UTC",
            "root",
            "195122"
        );
    statement=connection.createStatement();
    statement.executeUpdate(sql);
    connection.close();
    statement.close();

%>
</body>
</html>
